package com.tom.architect02.ui10.day09;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tom.architect02.R;

import java.util.ArrayList;
import java.util.List;

public class MainActivityUI09 extends AppCompatActivity {
    private TagLayout mTagLayout;
    private List<String> mData = new ArrayList();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_ui09);

        mData.add("Aaaa");
        mData.add("Abbbbb");
        mData.add("Acccccc");
        mData.add("Addddddd");
        mData.add("Aeeeeeeee");
        mData.add("Afff");
        mData.add("Aggg");
        mData.add("Ahhh");
        mData.add("Aiiisadfasdfasdf");

        mTagLayout = findViewById(R.id.tag_layout);
        mTagLayout.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return mData.size();
            }

            @Override
            public View getView(int position, ViewGroup parent) {
                LayoutInflater inflater = LayoutInflater.from(MainActivityUI09.this);
                TextView tagTv = (TextView) inflater.inflate(R.layout.item_tag, parent, false);
                tagTv.setText(mData.get(position));
//                tagTv.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                    }
//                });
                // 返回具体的childView.
                return tagTv;
            }
        });
    }

}

